package com.moos.example.bean;

import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.List;

public class BeanTest {
    public static void main(String[] args) {
        DiscussBean discussBean = new DiscussBean();

        DiscussBean.Data data = discussBean.new Data();


        List<DiscussDetailBean> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            DiscussDetailBean detailBean = new DiscussDetailBean();
            detailBean.setContent("1");
            detailBean.setCreateDate("1");
            detailBean.setId(1);
            detailBean.setImgId("1");
            detailBean.setLikes(1);
            detailBean.setNickName("1");
            detailBean.setRefs("1");
            detailBean.setReplyCount(1);
            detailBean.setTitle("1");
            detailBean.setUserLogo("1");
            list.add(detailBean);
        }

        data.setCount(1);
        data.setTotal(1);
        data.setList(list);

        discussBean.setCode(1);
        discussBean.setMessage("1");
        discussBean.setData(data);

        Gson gson = new Gson();
        String str = gson.toJson(discussBean);

        System.out.println(str);
        DiscussBean discussBean1 = gson.fromJson(str, DiscussBean.class);

        System.out.println(discussBean);
        System.out.println(discussBean1);
    }
}
